{{if false}}<script>{{/if}}
{{$controller = $smarty.const.CCTRL}}
{{$token = $smarty.const.TOKEN}}
{{include file="../base/function.tpl"}}
function handleEvents(){
    try{
         $("#jqxGrid").bind('rowselect', function (event) {
             var rowData=$("#jqxGrid").jqxGrid('getrowdata', event.args.rowindex);
             var ID = rowData._id;
             $("#detail").load("{{base_url()}}backend/admin/user/detail/"+ID);
             console.log(rowData);
         });
    }catch(e){tipMessage(e.message);}
}
function SaveItem(){
    try{
        
    }catch(e){
        console.log("JSON Error:"+e.message+"\n↵ Error");
        uiMessage(e.message);
        //ShowErrorDialogMessage("Sorry. Your request could not be completed.<br/> Please check your input data.");
    }
}
function changeprivilege(user_id,privilege_id,value,secretkey,signature){
    //if(getCheckedRadio(id)!==value){
        new backend({
			url         :   "{{"backend/admin/user/setprivilege"|base_url}}",
			data        :   {
				user_id		:	user_id,
				privilege_id:	privilege_id,
				permission	:	value,
				secretkey	:	secretkey,
				signature	:	signature
			},
			datatype    :   "json",
			callback    :   function(data){
				try{
					if(data.result<0){
						bckdialog({type:'error'}).open(data.message);
					}else{
						uiMessage(data.message);
					}
				}catch(e){
					bckdialog({type:'error'}).open("Sorry. Your request could not be completed.<br/> Please check your input data and try again.");
				}
				console.log(data);
			}
		}).call();
    //}
}
function getCheckedRadio(name) {
    var elements = document.getElementsByName(name);

    for (var i=0, len=elements.length; i<len; ++i)
        if (elements[i].checked) return elements[i].value;
}